package com.aijia.custom.product.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

import com.aijia.custom.product.R;
import com.aijia.custom.product.viewpage.MyViewPager;

import java.util.ArrayList;

/**
 * Created by yejianjun on 2019/1/21.
 */

public class Utils {

    /**
     * 强制隐藏键盘
     *
     * @param context
     * @param view
     */
    public static void hideSoftInput(Context context, View view) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0); // 强制隐藏键盘
    }

    public static void imageBrower(Context context, int position, ArrayList<String> imageUrls) {
        Intent intent = new Intent(context, MyViewPager.class);
        // 图片url,为了演示这里使用常量，一般从数据库中或网络中获取
        intent.putExtra(MyViewPager.EXTRA_IMAGE_URLS, imageUrls);
        intent.putExtra(MyViewPager.EXTRA_IMAGE_INDEX, position);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.zoom_enter, 0);
    }


}
